<html>
	<head>
		<title>IFrame PoC</title>
		 <style TYPE="text/css"> 
       <!-- 
			body {
                 background: black;
                 color: #80c0c0;      		  	 
			}
				  
			td {
				 font-family:Verdana,Arial,Helvetica,sans-serif;
				 font-size: 9pt;
			}
			input {
				 font-size: 9pt;
			}
			legend {
				color: white;
				font-family:Courier,sans-serif;								
			}
			a {
				color: orange;
				float: right;
			}
				  
				 
		-->
		</style>
		<script type="text/javascript">
			
			/**
			 * Sample function to show how imep_loadWmcFromUrl() can be used.
			 */
			function sample_loadWmcUrl()
			{
				var wmcurl = document.getElementById('wmcurl').value;
				var clear = document.getElementById('lwclearcontext').checked;
				
				window.frames.intermapIframe.imep_loadWmcFromUrl(wmcurl, clear); 
			}
			
			/**
			 * Sample function to show how imep_loadLayer() can be used.
			 */
			function sample_loadWmsLayer()
			{
				var url = document.getElementById('wmsurl').value;
				var layer = document.getElementById('layername').value;
				var clear = document.getElementById('llclearcontext').checked;

//			var d = document;
//			var f = d.frames ? d.frames['intermapIframe'] : d.getElementById('intermapIframe');
//			var p = f.document || f.contentWindow.document;
//			p.imep_loadLayer(url, layer);
			
				window.frames.intermapIframe.imep_loadLayer(url, layer, clear); // FF OK
			}

			/**
			 * Sample function to show how imep_setBBox() can be used.
			 */
			function sample_gotoBBox()
			{
				var bbn = document.getElementById('bbn').value;
				var bbe = document.getElementById('bbe').value;
				var bbs = document.getElementById('bbs').value;
				var bbw = document.getElementById('bbw').value;
			
				window.frames.intermapIframe.imep_setBBox(bbn, bbe, bbs, bbw); // FF OK
			}
		
			/**
			 * InterMap CallBack function <b>imcb_getBootWmcUrl()</b> <p>
			 * 
			 * Sets the WMC that intermap must show when loading.
			 * 
			 * If this function exists and returns a not null value,
			 * the returned value must be an array containing:
			 *  - [0]: the URL to a WMC context document; 
			 *  		The given WMC is the context InterMap will show as soon as it is loaded.
			 *  - [1]: true if the existing layer list has to be cleared, 
			 * 			or false if the context's layers have to be added to the existing ones.
			 * 
			 *  Note that if the user session is not open yet (i.e. the user is loading intermap 
			 *  for the first time in a while), there is no existing layer list and the map 
			 *  will be build only with the loaded WMC, in the same way as the param [1] was set to true.  
			 * 
			 *  When both imcb_getBootLayer() and imcb_getBootWmcUrl() are defined, 
			 *  only imcb_getBootWmcUrl() will be considered.
			 * 
			 * @return {Array} [0]: the URL of the WMC context file ; [1]: true if context has to be cleared
			 */			
			function imcb_getBootWmcUrl()
			{	
				var ret = new Array();
				ret[0] = "http://localhost:8080/intermap/static/context_australia.xml";
				ret[1] = true; 			
				return ret;
			}

			/**
			 * InterMap CallBack function <b>imcb_getBootLayer()</b><p>
			 * 
			 * Sets the layer that intermap must show when loading.
			 * 
			 * If this function exists and returns a not null value,
			 * the returned value must be an array containing:
			 *  - [0]: the URL to a WMS; 
			 *  - [1]: the name of the layer to load;
			 *  - [2]: true if the existing layer list has to be cleared, 
			 *      or false if the given layer has to be added to the existing ones.
			 *        
			 *  The given layer will be loaded in InterMap as soon as IM is loaded.
			 *  
			 *  Note that if the user session is not open yet (i.e. the user is loading intermap 
			 *  for the first time in a while), there is no existing layer list and the map 
			 *  will be build only with the loaded layer, in the same way as the param [2] was set to true.
			 * 
			 * When both imcb_getBootLayer() and imcb_getBootWmcUrl() are defined, 
			 * only imcb_getBootWmcUrl() will be considered.
			 * 
			 * @return {Array} [0]: the WMS URL; [1]: the layer's name; [2]: true if context has to be cleared
			 */			
			function imcb_getBootLayer()
			{	
				var ret = new Array();
				ret[0] = "http://www2.demis.nl/wms/wms.asp?wms=WorldMap&";
				ret[1] = "Countries";				
				ret[2] = true; 			
				return ret;
			}

		</script>
				 
	</head>
	
	<body>
		<table>
			<tbody>
				<tr height="100px">
					<td width="150px">row: 100px<br/>col: 150px</td>
					<td width="600px">col: 600px</td>
					<td rowspan="3">
						<fieldset>
							<legend>imep_loadWmcFromUrl</legend>
							WMC url 
							<input type="text" id="wmcurl" value="http://localhost:8080/intermap/static/context_australia.xml"/> 
							<br/>Clear context
							<input type="checkbox" id="lwclearcontext" title="Clear context"/>
							
							<br/><a href="javascript:void(0);" onclick="sample_loadWmcUrl();">LOAD CONTEXT</a>							
						</fieldset>
						
						<p/>
<!--
						WMS server url 
						<input type="text" id="wmsurl" value="http://ssems1.esrin.esa.int/ionicweb/wfs/FLOODS_FREQ_UNEP"/> 
						layer name 
						<input type="text" id="layername" value="global_floods_unep"/>
-->						
						<fieldset>
							<legend>imep_loadLayer</legend>
							WMS server URL 
							<input type="text" id="wmsurl" value="http://www2.demis.nl/wms/wms.asp?wms=WorldMap&"/> 
							<br/>Layer name 
							<input type="text" id="layername" value="Countries"/>
							<br/>Clear context
							<input type="checkbox" id="llclearcontext" title="Clear context"/>
							 
							<br/><a href="javascript:void(0);" onclick="sample_loadWmsLayer();">ADD LAYER</a>
						</fieldset>

						<p/>
						
						<fieldset>
							<legend>imep_setBBox</legend>
							N:<input type="text" id="bbn" value="-21.781"/>
							E:<input type="text" id="bbe" value="-53.65"/>
							<br/>
							S:<input type="text" id="bbs" value="-55.052"/>
							W:<input type="text" id="bbw" value="-73.582"/>
							
							<br/><a href="javascript:void(0);" onclick="sample_gotoBBox();">GOTO BBOX</a>												
						</fieldset>
					</td>
				</tr>
				
				<tr height="200px">
					<td>H: 200px</td>
					<td>
						<iframe width="600" height="200"
							id="intermapIframe" name="intermapIframe"
							src="/intermap/srv/en/skel"/>						
					</td>
					
				</tr>				
				<tr height="100px">
					<td>H: 100px</td>
					<td></td>
					
				</tr>				
			</tbody>
			
		</table>
		
		
	</body>

</html>
